<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>plugin</title>
    <script src = 'jquery-1.12.4.min.js'></script>
    <style>
        *{
            margin: 0 ;
            padding: 0;
        }
        img{
            border: 0 none;
            position: absolute;
        }
    </style>
    <script>
        jQuery(function () {

            $.bg=function(opt){
                $.each(opt.img,function (i,o) {
                    $('<img/>').css({
                        width:document.documentElement.clientWidth + 'px',
                        height:document.documentElement.clientHeight + 'px',
                        position: "absolute",
                        top:'0',
                        left:'0',
                        opacity:'0'
                    }).attr({'src':o}).addClass('path').appendTo(document.body)
                });

                $('.path').eq(0).css({opacity:1});

                $(window).resize(function () {
                    $('.path').width(document.documentElement.clientWidth).height(document.documentElement.clientHeight)
                });


                $('.path').data({'new_num':'0'});

                //切换
                window.setInterval(function () {
                    $('.path').eq($('.path').data('new_num')).animate({opacity:0},opt.t);
                    if($('.path').data('new_num') + 1 == opt.img.length){
                        $('.path').data({'new_num':'-1'});
                    }
                    $('.path').eq($('.path').data('new_num') + 1).animate({opacity:1},opt.t);

                    $('.path').data({
                        'new_num' : ($('.path').data('new_num')) + 1
                    });
                },opt.time*1000);

            };

            //调用
            $.bg({
                img:[
                    '../img/IMG_2172.JPG',
                    '../img/IMG_2173.JPG',
                    '../img/IMG_2174.JPG',
                    '../img/IMG_2175.JPG',
                    '../img/IMG_2176.JPG',
                    '../img/IMG_2177.JPG',
                    '../img/IMG_2178.JPG'
                ],
                time:2,
                t:500
            });

        });
    </script>
</head>
<body>
</body>
</html>